<%--
  Created by IntelliJ IDEA.
  User: 99299
  Date: 2015/10/15 0015
  Time: 21:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- 获取项目名 -->
<c:set var="BASE" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>customer</title>
</head>
<body>
<c:if test="${customer.id == null}">
  <h1>客户列表</h1><a href="/customer_create_pre">新增客户</a>
  <table>
    <tr>
      <th>客户名称</th>
      <th>联系人</th>
      <th>电话号码</th>
      <th>邮箱地址</th>
      <th>操作</th>
    </tr>
    <c:forEach var="customer" items="${customerList}">
      <tr>
        <td>${customer.name}</td>
        <td>${customer.contact}</td>
        <td>${customer.telephone}</td>
        <td>${customer.email}</td>
        <td>
          <a href="${BASE}/customer_edit?id=${customer.id}">编辑</a>
          <a href="${BASE}/customer_delete?id=${customer.id}">删除</a>
        </td>
      </tr>
    </c:forEach>
  </table>
</c:if>

  <c:if test="${customer.id != null}">
    <h1>修改客户信息</h1>
    <form name="f" action="/customer_update" method="post">
      <input type="hidden" name="id" value="${customer.id}">
      <p>姓名：<input type="text" name="name" value="${customer.name}"/></p>
      <p>联系地址：<input type="text" name="contact" value="${customer.contact}"/></p>
      <p>电话号码：<input type="text" name="telephone" value="${customer.telephone}"/></p>
      <p>邮箱：<input type="text" name="email" value="${customer.email}"/></p>
      <p><input type="submit" value="保存" /></p>
    </form>
  </c:if>
</body>
</html>
